package com.yt.project.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yt.project.common.BaseResponse;
import com.yt.project.common.ResultUtils;
import com.yt.project.model.dto.bilibili.BilibiliDescQueryRequest;
import com.yt.project.model.dto.bilibili.BilibiliQueryRequest;
import com.yt.project.model.entity.Bilibili;
import com.yt.project.model.vo.DescVO;
import com.yt.project.model.vo.BilibiliVO;
import com.yt.project.model.vo.TagDistVO;
import com.yt.project.service.BilibiliService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/bilibili")
public class BilibiliController {

    @Resource
    private BilibiliService bilibiliService;

    /**
     * 获取哔哩哔哩信息列表
     * @return
     */
    @PostMapping("/list")
    public BaseResponse<List<Bilibili>> getBilibiliList() {
        List<Bilibili> list = bilibiliService.list();
        return ResultUtils.success(list);
    }

    /**
     * 分页获取
     * @param bilibiliQueryRequest
     * @return
     */
    @PostMapping("/page")
    public BaseResponse<Page<BilibiliVO>> getBilibiliPage(@RequestBody BilibiliQueryRequest bilibiliQueryRequest) {

        Page<BilibiliVO> bilibiliVOPage = bilibiliService.pageBlibili(bilibiliQueryRequest);
        return ResultUtils.success(bilibiliVOPage);
    }


    @PostMapping("/desc")
    public BaseResponse<DescVO> getBilibiliDesc(@RequestBody BilibiliDescQueryRequest bilibiliDescQueryRequest) {
        DescVO descVO = bilibiliService.getDescById(bilibiliDescQueryRequest.getId());
        return ResultUtils.success(descVO);
    }


    @PostMapping("/dist/tags")
    public BaseResponse<List<TagDistVO>> getTagsDist(@RequestBody BilibiliDescQueryRequest bilibiliDescQueryRequest) {
        List<TagDistVO> tagDistVOS = bilibiliService.getTagsDist(bilibiliDescQueryRequest.getId());
        return ResultUtils.success(tagDistVOS);
    }
}
